package com.faithbj.device.utils;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component("systemConfigUtil")
public class SystemConfigUtil {

	// 货币种类（人民币、美元、欧元、英磅、加拿大元、澳元、卢布、港币、新台币、韩元、新加坡元、新西兰元、日元、马元、瑞士法郎、瑞典克朗、丹麦克朗、兹罗提、挪威克朗、福林、捷克克朗、葡币）
	public enum CurrencyType {
		CNY, USD, EUR, GBP, CAD, AUD, RUB, HKD, TWD, KRW, SGD, NZD, JPY, MYR, CHF, SEK, DKK, PLZ, NOK, HUF, CSK, MOP
	};
	
	// 小数位精确方式（四舍五入、向上取整、向下取整）
	public enum RoundType {
		roundHalfUp, roundUp, roundDown
	}
	
	// 库存预占时间点（下订单、订单付款、订单发货）
	public enum StoreFreezeTime {
		order, payment, ship
	}
	
	// 水印位置（无、左上、右上、居中、左下、右下）
	public enum WatermarkPosition {
		no, topLeft, topRight, center, bottomLeft, bottomRight
	}

	
    /**
     * 休息日时间，周日从1开始，用逗号分隔
     */
    @Value("${restDay}")
    private String restDay;
    /**
     * 在一日内休息时间，单位小时，用逗号分隔
     */
    @Value("${restHours}")
    private String restHours;
    
    //系统名称
    @Value("${systemName}")
    private String systemName;
    //系统版本
    @Value("${systemVersion}")
    private String systemVersion;
    //系统描述    
    @Value("${systemDescription}")
    private String systemDescription;    
    //公司地址
    @Value("${address}")
    private String address;    
    //电话
    @Value("${phone}")
    private String phone;    
    //邮编
    @Value("${zipCode}")
    private String zipCode;    
    //email
    @Value("${email}")
    private String email;    
    //备案信息
    @Value("${certtext}")
    private String certtext;    
    //上传照片大小限制，单位(M)兆
    @Value("${uploadLimit}")
    private Integer uploadLimit;  
    //是否启动自动锁定账号
    @Value("${isLoginFailureLock}")
    private Boolean isLoginFailureLock;  
    //连续登录失败最大次数
    @Value("${loginFailureLockCount}")
    private Integer loginFailureLockCount;  
    //自动解锁时间
    @Value("${loginFailureLockTime}")
    private Integer loginFailureLockTime;  
    
    
    
    //图片文件根路径
    @Value("${uploadImageDIR}")
    private String uploadImageDIR;    
    
    
    //水印图片文件路径
    @Value("${watermarkImagePath}")
    private String watermarkImagePath;    
    //水印图片位置
    @Value("${watermarkPosition}")
    private String watermarkPosition;    
    //水印图片透明度
    @Value("${watermarkAlpha}")
    private String watermarkAlpha;    
    //商品大图宽度
    @Value("${bigProductImageWidth}")
    private Integer bigProductImageWidth;    
    //商品大图高度
    @Value("${bigProductImageHeight}")
    private Integer bigProductImageHeight;    
    //商品小图宽度
    @Value("${smallProductImageWidth}")
    private Integer smallProductImageWidth;    
    //商品小图高度
    @Value("${smallProductImageHeight}")
    private Integer smallProductImageHeight;    
    //商品缩略小图宽度
    @Value("${thumbnailProductImageWidth}")
    private Integer thumbnailProductImageWidth;    
    //商品极缩略图高度
    @Value("${thumbnailProductImageHeight}")
    private Integer thumbnailProductImageHeight;    
    //默认大图片路径
    @Value("${defaultBigProductImagePath}")
    private String defaultBigProductImagePath;    
    //默认小图片路径
    @Value("${defaultSmallProductImagePath}")
    private String defaultSmallProductImagePath;    
    //允许上传的图片后缀
    @Value("${allowedUploadImageExtension}")
    private String allowedUploadImageExtension;    
    //允许上传的多媒体后缀
    @Value("${allowedUploadMediaExtension}")
    private String allowedUploadMediaExtension;    
    //允许上传的文件后缀
    @Value("${allowedUploadFileExtension}")
    private String allowedUploadFileExtension;    
    
	/**
	 * 最大预约天数
	 */
	@Value("${allowReservationDay}")
	private Integer allowReservationDay;
    
	/**
	 * 刷新系统配置信息
	 * 
	 */
	public void flush() {
//		OsCacheConfigUtil.flushEntry(SYSTEM_CONFIG_CACHE_KEY);
	}
	
	
	public String getSystemName() {
		return systemName;
	}

	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}

	public String getSystemVersion() {
		return systemVersion;
	}

	public void setSystemVersion(String systemVersion) {
		this.systemVersion = systemVersion;
	}

	public String getSystemDescription() {
		return systemDescription;
	}

	public void setSystemDescription(String systemDescription) {
		this.systemDescription = systemDescription;
	}


	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}



	public String getCerttext() {
		return certtext;
	}

	public void setCerttext(String certtext) {
		this.certtext = certtext;
	}


	public Integer getUploadLimit() {
		return uploadLimit;
	}

	public void setUploadLimit(Integer uploadLimit) {
		this.uploadLimit = uploadLimit;
	}

	public Boolean getIsLoginFailureLock() {
		return isLoginFailureLock;
	}

	public void setIsLoginFailureLock(Boolean isLoginFailureLock) {
		this.isLoginFailureLock = isLoginFailureLock;
	}

	public Integer getLoginFailureLockCount() {
		return loginFailureLockCount;
	}

	public void setLoginFailureLockCount(Integer loginFailureLockCount) {
		this.loginFailureLockCount = loginFailureLockCount;
	}

	public Integer getLoginFailureLockTime() {
		return loginFailureLockTime;
	}

	public void setLoginFailureLockTime(Integer loginFailureLockTime) {
		this.loginFailureLockTime = loginFailureLockTime;
	}

	public String getWatermarkImagePath() {
		return watermarkImagePath;
	}

	public void setWatermarkImagePath(String watermarkImagePath) {
		this.watermarkImagePath = watermarkImagePath;
	}

	public String getWatermarkPosition() {
		return watermarkPosition;
	}

	public void setWatermarkPosition(String watermarkPosition) {
		this.watermarkPosition = watermarkPosition;
	}

	public String getWatermarkAlpha() {
		return watermarkAlpha;
	}

	public void setWatermarkAlpha(String watermarkAlpha) {
		this.watermarkAlpha = watermarkAlpha;
	}

	public Integer getBigProductImageWidth() {
		return bigProductImageWidth;
	}

	public void setBigProductImageWidth(Integer bigProductImageWidth) {
		this.bigProductImageWidth = bigProductImageWidth;
	}

	public Integer getBigProductImageHeight() {
		return bigProductImageHeight;
	}

	public void setBigProductImageHeight(Integer bigProductImageHeight) {
		this.bigProductImageHeight = bigProductImageHeight;
	}

	public Integer getSmallProductImageWidth() {
		return smallProductImageWidth;
	}

	public void setSmallProductImageWidth(Integer smallProductImageWidth) {
		this.smallProductImageWidth = smallProductImageWidth;
	}

	public Integer getSmallProductImageHeight() {
		return smallProductImageHeight;
	}

	public void setSmallProductImageHeight(Integer smallProductImageHeight) {
		this.smallProductImageHeight = smallProductImageHeight;
	}

	public Integer getThumbnailProductImageWidth() {
		return thumbnailProductImageWidth;
	}

	public void setThumbnailProductImageWidth(Integer thumbnailProductImageWidth) {
		this.thumbnailProductImageWidth = thumbnailProductImageWidth;
	}

	public Integer getThumbnailProductImageHeight() {
		return thumbnailProductImageHeight;
	}

	public void setThumbnailProductImageHeight(Integer thumbnailProductImageHeight) {
		this.thumbnailProductImageHeight = thumbnailProductImageHeight;
	}

	public String getDefaultBigProductImagePath() {
		return defaultBigProductImagePath;
	}

	public void setDefaultBigProductImagePath(String defaultBigProductImagePath) {
		this.defaultBigProductImagePath = defaultBigProductImagePath;
	}

	public String getDefaultSmallProductImagePath() {
		return defaultSmallProductImagePath;
	}

	public void setDefaultSmallProductImagePath(String defaultSmallProductImagePath) {
		this.defaultSmallProductImagePath = defaultSmallProductImagePath;
	}

	public String getAllowedUploadImageExtension() {
		return allowedUploadImageExtension;
	}

	public void setAllowedUploadImageExtension(String allowedUploadImageExtension) {
		this.allowedUploadImageExtension = allowedUploadImageExtension;
	}

	public String getAllowedUploadMediaExtension() {
		return allowedUploadMediaExtension;
	}

	public void setAllowedUploadMediaExtension(String allowedUploadMediaExtension) {
		this.allowedUploadMediaExtension = allowedUploadMediaExtension;
	}

	public String getAllowedUploadFileExtension() {
		return allowedUploadFileExtension;
	}

	public void setAllowedUploadFileExtension(String allowedUploadFileExtension) {
		this.allowedUploadFileExtension = allowedUploadFileExtension;
	}

	public String getUploadImageDIR() {
		return uploadImageDIR;
	}

	public void setUploadImageDIR(String uploadImageDIR) {
		this.uploadImageDIR = uploadImageDIR;
	}

	public Integer getAllowReservationDay() {
		return allowReservationDay;
	}

	public void setAllowReservationDay(Integer allowReservationDay) {
		this.allowReservationDay = allowReservationDay;
	}
	public void setRestDay(String restDay) {
		this.restDay = restDay;
	}

	public String getRestDay() {
		return restDay;
	}
	
	public String getRestHours() {
		return restHours;
	}


	public void setRestHours(String restHours) {
		this.restHours = restHours;
	}


	
	
	/**
	 * 将以逗号隔开的字符串日期转化为星期几，获得休息日的日期，是休息日返回1，否则返回null
	 * @return
	 */
	public Map<Integer,Integer> getRestDaysOfWeek() {
		if(StringUtils.isBlank(restDay))
			restDay="1,7";
		String[] tempArray=restDay.split(",");
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(String array:tempArray){
			map.put(Integer.parseInt(array),1);
		}
		return map;
	}

	/**
	 * 将以逗号隔开的字符串小时转化为当天几点，获得每日的休息时间(几点休息)，是休息时间返回1，否则返回null
	 * @return
	 */
	public Map<Integer,Integer> getRestHoursOfDay() {
		if(StringUtils.isBlank(restHours))
			restHours="0,1,2,3,4,5,6,7,23";
		String[] tempArray=restHours.split(",");
		Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(String array:tempArray){
			map.put(Integer.parseInt(array),1);
		}
		return map;
	}



	
}
